package com.lc.luzhengtang.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lc.luzhengtang.R;
import com.lc.luzhengtang.bean.CommentDetailBean;
import com.lc.luzhengtang.conn.Conn;
import com.zcx.helper.scale.ScaleScreenHelperFactory;

import java.util.List;

/**
 * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
 */
public class CommentSectionAdapter2 extends BaseQuickAdapter<CommentDetailBean.DataBean, BaseViewHolder> {


    public CommentSectionAdapter2(List<CommentDetailBean.DataBean> data) {
        super(R.layout.item_comment_xiugai, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, final CommentDetailBean.DataBean item) {
        ScaleScreenHelperFactory.getInstance().loadView((ViewGroup) helper.convertView);


        Glide.with(mContext).load(Conn.HOST3 + item.getPicurl()).crossFade().error(R.mipmap.zhanwei).placeholder(R.mipmap.zhanwei).into((ImageView) helper.getView(R.id.img_shop));
        helper.setText(R.id.text_newstime, item.getGoods_title());
//        helper.setText(R.id.text_newstitle, "￥"+item.getSales());
        helper.setText(R.id.text_he, item.getGoods_attr());
        helper.setText(R.id.text_price, "¥" + item.getSales());
//        helper.setTag(R.id.text_num2,"X"+item.getNum()+"");
        helper.setText(R.id.text_num, "X" + item.getNum() + "");
//        helper.setText(R.id.text_content, item.getContent());

        helper.setText(R.id.text_content, item.getContent());

//        1好评 2中评 3差评
        if (item.getEvaluate().equals("1")) {
            helper.setText(R.id.text_status, "好评");
            helper.setImageResource(R.id.img_status, R.mipmap.comment_selected);
            helper.setVisible(R.id.textView4, false);
        } else if (item.getEvaluate().equals("2")) {
            helper.setText(R.id.text_status, "中评");
            helper.setImageResource(R.id.img_status, R.mipmap.comment_unselected);
            helper.setVisible(R.id.textView4, false);
        } else {
            helper.setText(R.id.text_status, "差评");
            helper.setImageResource(R.id.img_status, R.mipmap.comment_unselected);
            helper.setVisible(R.id.textView4, true);
        }

        helper.addOnClickListener(R.id.textView4);

        View view = helper.getConvertView();
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                CommentListActivity
//                mContext.startActivity(new Intent(mContext, CommentListActivity2.class));
              /*  Intent intent = new Intent();
                intent.putExtra("ordersn",item.getOrdersn());
//                status

                intent.setClass(mContext, OrderDetailActivity2.class);
                mContext.startActivity(intent);*/
            }
        });
    }


}
